package com.share.service.site.navigation.impl;

import java.util.Date;
import java.util.List;

import org.springframework.stereotype.Component;

import com.share.bean.site.SiteNaviItem;
import com.share.commons.base.dao.BaseDaoSupport;
import com.share.service.site.navigation.SiteNaviItemManager;

/**
 * <p>Title：导航条分类接口实现， 不经过DAO接口</p>
 * <p>Description：</p>
 * @Author：杨浩泉
 * @Date：2010-4-13
 */
@Component
public class SiteNaviItemManagerImpl extends BaseDaoSupport<SiteNaviItem> implements SiteNaviItemManager {

	@Override
	public void delete(int id) throws RuntimeException {
		this.deleteObject(this.loadById(id)) ;
	}

	@SuppressWarnings("unchecked")
	@Override
	public List find() throws RuntimeException {
		
		String hql = "select o from SiteNaviItem o" ;
		
		return (List) this.find(hql) ;
	}

	@Override
	public void save(Object entity) throws RuntimeException {
		SiteNaviItem sni = (SiteNaviItem)entity ;
		sni.setAddTime(new Date()) ;
		this.saveObject(sni) ;
	}

	@Override
	public void update(Object entity) throws RuntimeException {
		SiteNaviItem sni = (SiteNaviItem)entity ;
		sni.setAddTime(new Date()) ;
		this.updateObject(sni) ;
	}	

	@Override
	public SiteNaviItem loadById(int id) throws RuntimeException {
		return this.loadById(SiteNaviItem.class, id) ;
	}

}
